import 'package:flutter/material.dart';
import 'package:yurun_smartmerchants/models/good_list_entity.dart';
import 'package:yurun_smartmerchants/page/inventory_batch.dart';
import 'package:yurun_smartmerchants/page/inventory_details.dart';
import 'package:yurun_smartmerchants/res/colours.dart';

class InventoryDetailPage extends StatefulWidget{
  final GoodListContent goodContent;

  InventoryDetailPage({this.goodContent});

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _InventoryDetailPageState();
  }

}

class _InventoryDetailPageState extends State<InventoryDetailPage> with SingleTickerProviderStateMixin{
  TabController _tabController;
  PageController _pageController = PageController();
  List<String> titles = ['库存批次','库存明细'];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = TabController(length: titles.length, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colours.white,
        centerTitle: true,
        iconTheme: IconThemeData(color: Colours.app_words),
        title: Text(
          widget.goodContent.categoryiiiName,
          style: TextStyle(fontSize: 18, color: Colours.app_words),
        ),
        bottom: TabBar(
            tabs: <Widget>[
              Tab(text: titles[0],),
              Tab(text: titles[1],)
            ],
            controller: _tabController,
            indicatorColor: Colours.color_dd4b39,
            labelColor: Colours.color_dd4b39,
            unselectedLabelColor: Colours.color_434343,
            indicatorSize: TabBarIndicatorSize.label,
            indicatorWeight: 2,
            onTap: (index){
              _pageController.jumpToPage(index);
            },
        ),
      ),
      body: PageView(
        controller: _pageController,
        children: <Widget>[
          InventoryBatchPage(goodContent: widget.goodContent,),
          InventoryDetailsPage(goodContent: widget.goodContent,)
        ],
        onPageChanged: (index){
          _tabController.animateTo(index);
        },
      ),
    );
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    _tabController.dispose();
    _pageController.dispose();
  }

//  List<Widget> pages = <Widget>[
//    InventoryBatchPage(goodContent: widget.goodContent,),
//    InventoryDetailsPage()
//  ];
}